/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VistaProyecto.java
 *
 * Created on 01/10/2011, 12:26:38 AM
 */
package GUI.AdministracionProyectos;

import BE.Cliente;
import BE.PapelTrabajo;
import BE.Proyecto;
import BE.Hallazgo;
import BE.PlantillaMarcoReferencia;
import BE.Recomendacion;
import BL.ClienteBl;
import BL.HallazgoBl;
import BL.PapelTrabajoBl;
import BL.PlantillaMarcoReferenciaBl;
import BL.ProyectoBl;
import BL.RecomendacionBl;
import GUI.AdministracionPlantillas.BusquedaMarcoReferencia;
import GUI.Principal;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author CarLita
 */
public class VistaProyecto extends javax.swing.JPanel {

    Principal ventanaPrincipal;
    Proyecto proyecto;
    int modoVentana;
    ClienteBl clienteBl;
    Cliente cliente;
    List papelesTrabajo;
    PapelTrabajoBl papelTrabajoBl;
    ProyectoBl proyectoBl;
    PapelTrabajo documentoAsociado = null;
    private PlantillaMarcoReferencia marcoReferencia;

    public VistaProyecto(Principal ventanaPrincipal) {
        this.ventanaPrincipal = ventanaPrincipal;
        clienteBl = new ClienteBl();
        papelTrabajoBl = new PapelTrabajoBl();
        initComponents();
        cliente = new Cliente();
        proyectoBl = new ProyectoBl();
        btnAgregar.setVisible(false);
        btnAgregar.setEnabled(false);
        
    }

    void setearModo(int modo) {
        switch (modo) {
            case Principal.MODO_LECTURA:
                llenarInfoProyecto(proyecto);
                desbloquearCampos(false);
                btnEditar.setVisible(true);
                btnGuardar.setVisible(false);
                break;
            case Principal.MODO_EDICION:
                //edicion y llenado
                llenarInfoProyecto(proyecto);
                desbloquearCampos(true);
                btnEditar.setVisible(false);
                btnGuardar.setVisible(true);
                buscarHallazgos();
                buscarRecomendaciones();
                break;
        }
    }

    private void ocultarIdTablaHallazgos() {
        tblHallazgos.getColumn("Id").setWidth(0);
        tblHallazgos.getColumn("Id").setMinWidth(0);
        tblHallazgos.getColumn("Id").setMaxWidth(0);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabPan = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        txtDescripcion = new javax.swing.JTextField();
        txtObjetivos = new javax.swing.JTextField();
        txtMarcoReferencia = new javax.swing.JTextField();
        btnBusquedaMarco = new javax.swing.JButton();
        lblEstado = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jTextField7 = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        btnCompletar = new javax.swing.JButton();
        dateInicio = new com.toedter.calendar.JDateChooser();
        dateFin = new com.toedter.calendar.JDateChooser();
        jPanel5 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        txtRazonSocial = new javax.swing.JTextField();
        txtDireccion = new javax.swing.JTextField();
        txtRUC = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        txtCorreo = new javax.swing.JTextField();
        txtContacto = new javax.swing.JTextField();
        btnCancelar = new javax.swing.JButton();
        btnEditar = new javax.swing.JButton();
        btnGuardar = new javax.swing.JButton();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        btnGenerarInforme = new javax.swing.JButton();
        btnGenerarReporte = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblPapelTrabajo = new javax.swing.JTable();
        btnCompletarPt = new javax.swing.JButton();
        btnEditarPT = new javax.swing.JButton();
        btnEliminarPt = new javax.swing.JButton();
        btnAgregar = new javax.swing.JButton();
        btnRefrescarPT = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblHallazgos = new javax.swing.JTable();
        btnAgregarHallazgo = new javax.swing.JButton();
        btnEditarHallazgo = new javax.swing.JButton();
        btnEliminarHallazgo = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        txtTituloHallazgo = new javax.swing.JTextField();
        btnBuscar = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtDocumentoAsociado = new javax.swing.JTextField();
        btnNuevoHallazgo = new javax.swing.JButton();
        cmbScoreHallazgo = new javax.swing.JComboBox();
        btnBuscarHallazgo = new javax.swing.JButton();
        btnRefrescarHallazgos = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblRecomendaciones = new javax.swing.JTable();
        btnAgregarRecomendacion = new javax.swing.JButton();
        btnEditarRecomendacion = new javax.swing.JButton();
        btnEliminarRecomendacion = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        btnBuscarRecomendacion = new javax.swing.JButton();
        txtTituloRecomendacion = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        btnNuevaRecomendacion = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        txtRecomendacion = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        cmbScoreRecomendacion = new javax.swing.JComboBox();
        btnRefrescarRecomendaciones = new javax.swing.JButton();

        ocultarIdTablaRecomendaciones();

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información del Proyecto", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 13))); // NOI18N

        jLabel4.setText("Marco de Referencia:");

        jLabel3.setText("Objetivos:");

        jLabel1.setText("Nombre:");

        jLabel6.setText("Fin:");

        jLabel19.setText("Equipo:");
        jLabel19.setEnabled(false);

        jLabel17.setText("Auditor Líder:");
        jLabel17.setEnabled(false);

        jLabel5.setText("Fecha  Inicio:");

        jLabel15.setText("Estado Proyecto:");

        jLabel2.setText("Descripción:");

        btnBusquedaMarco.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionProyectos/find.gif"))); // NOI18N
        btnBusquedaMarco.setText("Buscar");
        btnBusquedaMarco.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBusquedaMarcoActionPerformed(evt);
            }
        });

        lblEstado.setText("<estado>");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Juan Perez" }));
        jComboBox1.setEnabled(false);

        jTextField7.setEnabled(false);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionProyectos/agregar.png"))); // NOI18N
        jButton2.setEnabled(false);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/minus white.png"))); // NOI18N
        jButton3.setEnabled(false);

        btnCompletar.setText("Completar");
        btnCompletar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCompletarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(34, 34, 34)
                        .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(15, 15, 15))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(txtDescripcion, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
                        .addGap(15, 15, 15))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 318, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGap(76, 76, 76)
                                .addComponent(txtObjetivos, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
                                .addGap(5, 5, 5))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel15)
                                        .addGap(18, 18, 18)
                                        .addComponent(lblEstado))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addGap(18, 18, 18)
                                        .addComponent(dateInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGap(96, 96, 96)
                                        .addComponent(btnCompletar))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel6)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(dateFin, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                        .addGap(10, 10, 10))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(txtMarcoReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnBusquedaMarco))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addGap(10, 10, 10))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(jTextField7, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButton3, 0, 0, Short.MAX_VALUE)
                            .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, Short.MAX_VALUE))
                        .addGap(26, 26, 26)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtObjetivos, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtMarcoReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBusquedaMarco))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(dateInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(dateFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(13, 13, 13)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel15)
                        .addComponent(lblEstado))
                    .addComponent(btnCompletar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3))
                    .addComponent(jTextField7, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE))
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información del Cliente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 13))); // NOI18N

        jLabel12.setText("RUC:");

        jLabel13.setText("Razón Social:");

        jLabel14.setText("Dirección:");

        jLabel16.setText("Teléfono:");

        jLabel18.setText("Correo:");

        jLabel20.setText("Nombre Contacto:");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel20)
                    .addComponent(jLabel18)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14)
                    .addComponent(jLabel16))
                .addGap(4, 4, 4)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtRUC, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtRazonSocial, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtContacto, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(43, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(26, 26, 26)
                        .addComponent(jLabel13)
                        .addGap(26, 26, 26)
                        .addComponent(jLabel14)
                        .addGap(26, 26, 26)
                        .addComponent(jLabel16))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(txtRUC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(txtRazonSocial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel18)
                    .addComponent(txtCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(txtContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(52, Short.MAX_VALUE))
        );

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/cancelar.png"))); // NOI18N
        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/edit.gif"))); // NOI18N
        btnEditar.setText("Editar");
        btnEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarActionPerformed(evt);
            }
        });

        btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/guardar.png"))); // NOI18N
        btnGuardar.setText("Guardar");
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });

        btnGenerarInforme.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionProyectos/documento.png"))); // NOI18N
        btnGenerarInforme.setText("<html>Generar informe final");
        btnGenerarInforme.setEnabled(false);
        btnGenerarInforme.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGenerarInforme.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGenerarInforme.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGenerarInformeActionPerformed(evt);
            }
        });
        btnGenerarInforme.setBounds(40, 10, 90, 80);
        jLayeredPane1.add(btnGenerarInforme, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btnGenerarReporte.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionProyectos/reporte estado.png"))); // NOI18N
        btnGenerarReporte.setText("<html> Generar reporte de estado");
        btnGenerarReporte.setEnabled(false);
        btnGenerarReporte.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGenerarReporte.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGenerarReporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGenerarReporteActionPerformed(evt);
            }
        });
        btnGenerarReporte.setBounds(150, 10, 92, 80);
        jLayeredPane1.add(btnGenerarReporte, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(148, 148, 148)
                        .addComponent(btnEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(74, 74, 74)
                        .addComponent(btnGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(63, 63, 63)
                        .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(120, 120, 120))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnEditar)
                        .addComponent(btnCancelar))
                    .addComponent(btnGuardar))
                .addContainerGap())
        );

        tabPan.addTab("Información Proyecto", jPanel1);

        tblPapelTrabajo.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null}
            },
            new String [] {
                "Id", "Nombre"
            }
        ));
        ocultarIdTablaPt();
        tblPapelTrabajo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tblPapelTrabajoMousePressed(evt);
            }
        });
        jScrollPane2.setViewportView(tblPapelTrabajo);

        btnCompletarPt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionProyectos/llenar doc.png"))); // NOI18N
        btnCompletarPt.setText("<html>  Completar");
        btnCompletarPt.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCompletarPt.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCompletarPt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCompletarPtActionPerformed(evt);
            }
        });

        btnEditarPT.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/edit.gif"))); // NOI18N
        btnEditarPT.setText("Editar");
        btnEditarPT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarPTActionPerformed(evt);
            }
        });

        btnEliminarPt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/minus white.png"))); // NOI18N
        btnEliminarPt.setText("Eliminar");
        btnEliminarPt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarPtActionPerformed(evt);
            }
        });

        btnAgregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionProyectos/agregar.png"))); // NOI18N
        btnAgregar.setText("Agregar");
        btnAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarActionPerformed(evt);
            }
        });

        btnRefrescarPT.setText("Refrescar");
        btnRefrescarPT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefrescarPTActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 618, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnAgregar, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(btnCompletarPt, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(btnRefrescarPT, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnEliminarPt, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnEditarPT, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addComponent(btnCompletarPt, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnEditarPT)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnEliminarPt)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRefrescarPT)
                        .addGap(55, 55, 55)
                        .addComponent(btnAgregar))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        tabPan.addTab("Papeles de Trabajo", jPanel2);

        tblHallazgos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {},
            new String [] {
                "Id", "Hallazgo", "Score"
            }
        ));
        ocultarIdTablaHallazgos();
        tblHallazgos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tblHallazgosMousePressed(evt);
            }
        });
        jScrollPane1.setViewportView(tblHallazgos);

        btnAgregarHallazgo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/new doc.png"))); // NOI18N
        btnAgregarHallazgo.setText("<html>Agregar Hallazgo");
        btnAgregarHallazgo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAgregarHallazgo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnAgregarHallazgo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarHallazgoActionPerformed(evt);
            }
        });

        btnEditarHallazgo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/edit.gif"))); // NOI18N
        btnEditarHallazgo.setText("Editar");
        btnEditarHallazgo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarHallazgoActionPerformed(evt);
            }
        });

        btnEliminarHallazgo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/minus white.png"))); // NOI18N
        btnEliminarHallazgo.setText("Eliminar");
        btnEliminarHallazgo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarHallazgoActionPerformed(evt);
            }
        });

        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel9.setText("Score:");

        btnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionProyectos/find.gif"))); // NOI18N
        btnBuscar.setText("Buscar");

        jLabel7.setText("Documento Asociado:");

        jLabel8.setText("Título:");

        btnNuevoHallazgo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/new doc.png"))); // NOI18N
        btnNuevoHallazgo.setText("<html>Nuevo Hallazgo");
        btnNuevoHallazgo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNuevoHallazgo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNuevoHallazgo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoHallazgoActionPerformed(evt);
            }
        });

        cmbScoreHallazgo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-", "1", "2", "3", "4", "5" }));

        btnBuscarHallazgo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/find.png"))); // NOI18N
        btnBuscarHallazgo.setText("Buscar");
        btnBuscarHallazgo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnBuscarHallazgo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnBuscarHallazgo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarHallazgoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)
                        .addComponent(txtTituloHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, 407, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(10, 10, 10)
                        .addComponent(txtDocumentoAsociado, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(cmbScoreHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(217, 217, 217)
                        .addComponent(btnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(40, 40, 40)
                .addComponent(btnBuscarHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(btnNuevoHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(32, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jLabel8))
                            .addComponent(txtTituloHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jLabel7))
                            .addComponent(txtDocumentoAsociado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jLabel9))
                            .addComponent(cmbScoreHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addComponent(btnBuscar))
                    .addComponent(btnBuscarHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnNuevoHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        btnRefrescarHallazgos.setText("Refrescar");
        btnRefrescarHallazgos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefrescarHallazgosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 575, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnRefrescarHallazgos, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(btnEliminarHallazgo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnAgregarHallazgo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                        .addComponent(btnEditarHallazgo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(23, 23, 23))
            .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(btnAgregarHallazgo, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnEditarHallazgo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnEliminarHallazgo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRefrescarHallazgos))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        tabPan.addTab("Hallazgos", jPanel3);

        tblRecomendaciones.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {},
            new String [] {
                "Id", "Recomendacion", "Score"
            }
        ));
        ocultarIdTablaRecomendaciones();
        tblRecomendaciones.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tblRecomendacionesMousePressed(evt);
            }
        });
        jScrollPane3.setViewportView(tblRecomendaciones);

        btnAgregarRecomendacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/new doc.png"))); // NOI18N
        btnAgregarRecomendacion.setText("<html>Agregar Recomendación");
        btnAgregarRecomendacion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAgregarRecomendacion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnAgregarRecomendacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarRecomendacionActionPerformed(evt);
            }
        });

        btnEditarRecomendacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/edit.gif"))); // NOI18N
        btnEditarRecomendacion.setText("Editar");
        btnEditarRecomendacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarRecomendacionActionPerformed(evt);
            }
        });

        btnEliminarRecomendacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/minus white.png"))); // NOI18N
        btnEliminarRecomendacion.setText("Eliminar");
        btnEliminarRecomendacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarRecomendacionActionPerformed(evt);
            }
        });

        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnBuscarRecomendacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/find.png"))); // NOI18N
        btnBuscarRecomendacion.setText("Buscar");
        btnBuscarRecomendacion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnBuscarRecomendacion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnBuscarRecomendacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarRecomendacionActionPerformed(evt);
            }
        });

        jLabel10.setText("Título:");

        btnNuevaRecomendacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/AdministracionPlantillas/new doc.png"))); // NOI18N
        btnNuevaRecomendacion.setText("<html>Nueva Recomendación");
        btnNuevaRecomendacion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNuevaRecomendacion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNuevaRecomendacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevaRecomendacionActionPerformed(evt);
            }
        });

        jLabel11.setText("Recomendación:");

        jLabel22.setText("Score:");

        cmbScoreRecomendacion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-", "1", "2", "3", "4", "5" }));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jLabel10)
                    .addComponent(jLabel22))
                .addGap(22, 22, 22)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, 368, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTituloRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbScoreRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 55, Short.MAX_VALUE)
                .addComponent(btnBuscarRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnNuevaRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(btnNuevaRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel7Layout.createSequentialGroup()
                            .addComponent(btnBuscarRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap())
                        .addGroup(jPanel7Layout.createSequentialGroup()
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txtTituloRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel10))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txtRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel11))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cmbScoreRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel22))
                            .addGap(25, 25, 25)))))
        );

        btnRefrescarRecomendaciones.setText("Refrescar");
        btnRefrescarRecomendaciones.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefrescarRecomendacionesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 575, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnAgregarRecomendacion, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                    .addComponent(btnEditarRecomendacion, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                    .addComponent(btnEliminarRecomendacion, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
                    .addComponent(btnRefrescarRecomendaciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(btnAgregarRecomendacion, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addComponent(btnEditarRecomendacion)
                        .addGap(11, 11, 11)
                        .addComponent(btnEliminarRecomendacion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnRefrescarRecomendaciones))))
        );

        tabPan.addTab("Recomendaciones", jPanel6);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabPan, javax.swing.GroupLayout.PREFERRED_SIZE, 773, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabPan, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnEliminarHallazgoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarHallazgoActionPerformed
       if (tblHallazgos.getSelectedRow()==-1){
            JOptionPane.showMessageDialog(this, "Seleccione el hallazgo a eliminar", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        else {
                 eliminarHallazgo();
         }
    }//GEN-LAST:event_btnEliminarHallazgoActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        limpiar();
        mostrarMantProyectos();
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnCompletarPtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCompletarPtActionPerformed
        if (tblPapelTrabajo.getSelectedRow() == -1) {
            JOptionPane.showMessageDialog(this, "Seleccione el papel de trabajo a completar", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        completarPT();
    }//GEN-LAST:event_btnCompletarPtActionPerformed

    private void btnNuevoHallazgoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoHallazgoActionPerformed
        new RedaccionHallazgos(proyecto.getIdproyecto(), ventanaPrincipal).setVisible(true);
    }//GEN-LAST:event_btnNuevoHallazgoActionPerformed

    private void btnAgregarHallazgoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarHallazgoActionPerformed
        new RedaccionHallazgos(proyecto.getIdproyecto(), ventanaPrincipal).setVisible(true);
    }//GEN-LAST:event_btnAgregarHallazgoActionPerformed

    private void btnEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarActionPerformed
        modoVentana = Principal.MODO_EDICION;
        setearModo(modoVentana);
    }//GEN-LAST:event_btnEditarActionPerformed

    private void tblPapelTrabajoMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblPapelTrabajoMousePressed
        if (evt.getClickCount() > 1) {
            mostrarPapelTrabajo(); 
            buscarPapeles();
        }
    }//GEN-LAST:event_tblPapelTrabajoMousePressed

    private void btnEditarPTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarPTActionPerformed
        if (tblPapelTrabajo.getSelectedRow() == -1) {
            JOptionPane.showMessageDialog(this, "Seleccione el papel de trabajo a completar", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        editarPapelTrabajo();
    }//GEN-LAST:event_btnEditarPTActionPerformed

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        guardarCambios();
    }//GEN-LAST:event_btnGuardarActionPerformed

private void btnBusquedaMarcoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBusquedaMarcoActionPerformed
    if (modoVentana == Principal.MODO_EDICION) buscarMarco();
}//GEN-LAST:event_btnBusquedaMarcoActionPerformed

private void btnCompletarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCompletarActionPerformed
    completarProyecto();
}//GEN-LAST:event_btnCompletarActionPerformed

private void btnGenerarInformeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerarInformeActionPerformed
    generarInforme();
}//GEN-LAST:event_btnGenerarInformeActionPerformed

private void btnGenerarReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerarReporteActionPerformed
    generarReporte();
}//GEN-LAST:event_btnGenerarReporteActionPerformed

private void btnBuscarHallazgoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarHallazgoActionPerformed
    buscarHallazgos();
}//GEN-LAST:event_btnBuscarHallazgoActionPerformed

private void btnEditarHallazgoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarHallazgoActionPerformed
    if (tblHallazgos.getSelectedRow()==-1){
        JOptionPane.showMessageDialog(this, "Seleccione el hallazgo a editar", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }    
    editarHallazgo();   
    
}//GEN-LAST:event_btnEditarHallazgoActionPerformed

private void btnEliminarRecomendacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarRecomendacionActionPerformed
    if (tblRecomendaciones.getSelectedRow()==-1){
        JOptionPane.showMessageDialog(this, "Seleccione la recomendación a eliminar", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    
    eliminarRecomendacion();
    
}//GEN-LAST:event_btnEliminarRecomendacionActionPerformed

private void btnAgregarRecomendacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarRecomendacionActionPerformed
    new RedaccionRecomendaciones(proyecto.getIdproyecto(), ventanaPrincipal).setVisible(true);
}//GEN-LAST:event_btnAgregarRecomendacionActionPerformed

private void btnNuevaRecomendacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevaRecomendacionActionPerformed
    new RedaccionRecomendaciones(proyecto.getIdproyecto(), ventanaPrincipal).setVisible(true);
}//GEN-LAST:event_btnNuevaRecomendacionActionPerformed

private void btnBuscarRecomendacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarRecomendacionActionPerformed
    buscarRecomendaciones();
}//GEN-LAST:event_btnBuscarRecomendacionActionPerformed

private void btnEditarRecomendacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarRecomendacionActionPerformed
    if (tblRecomendaciones.getSelectedRow()==-1){
        JOptionPane.showMessageDialog(this, "Seleccione la recomendación a eliminar", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    editarRecomendacion();
    
}//GEN-LAST:event_btnEditarRecomendacionActionPerformed

private void btnEliminarPtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarPtActionPerformed
     if (tblPapelTrabajo.getSelectedRow()==-1){
        JOptionPane.showMessageDialog(this, "Seleccione el papel de trabajo a eliminar", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
     eliminarPapelTrabajo();
    
}//GEN-LAST:event_btnEliminarPtActionPerformed

private void btnRefrescarPTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefrescarPTActionPerformed
    buscarPapeles();
}//GEN-LAST:event_btnRefrescarPTActionPerformed

private void btnRefrescarHallazgosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefrescarHallazgosActionPerformed
    buscarHallazgos();
}//GEN-LAST:event_btnRefrescarHallazgosActionPerformed

private void btnRefrescarRecomendacionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefrescarRecomendacionesActionPerformed
    buscarRecomendaciones();
}//GEN-LAST:event_btnRefrescarRecomendacionesActionPerformed

private void tblRecomendacionesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblRecomendacionesMousePressed
    if (evt.getClickCount()>1){
        verRecomendacion();
        buscarRecomendaciones();
    }
        
}//GEN-LAST:event_tblRecomendacionesMousePressed

private void tblHallazgosMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblHallazgosMousePressed
    if (evt.getClickCount()>1){
        verHallazgo();
        buscarHallazgos();
    }
        
}//GEN-LAST:event_tblHallazgosMousePressed

private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarActionPerformed
        agregarPapelTrabajo();
}//GEN-LAST:event_btnAgregarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregar;
    private javax.swing.JButton btnAgregarHallazgo;
    private javax.swing.JButton btnAgregarRecomendacion;
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnBuscarHallazgo;
    private javax.swing.JButton btnBuscarRecomendacion;
    private javax.swing.JButton btnBusquedaMarco;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnCompletar;
    private javax.swing.JButton btnCompletarPt;
    private javax.swing.JButton btnEditar;
    private javax.swing.JButton btnEditarHallazgo;
    private javax.swing.JButton btnEditarPT;
    private javax.swing.JButton btnEditarRecomendacion;
    private javax.swing.JButton btnEliminarHallazgo;
    private javax.swing.JButton btnEliminarPt;
    private javax.swing.JButton btnEliminarRecomendacion;
    private javax.swing.JButton btnGenerarInforme;
    private javax.swing.JButton btnGenerarReporte;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnNuevaRecomendacion;
    private javax.swing.JButton btnNuevoHallazgo;
    private javax.swing.JButton btnRefrescarHallazgos;
    private javax.swing.JButton btnRefrescarPT;
    private javax.swing.JButton btnRefrescarRecomendaciones;
    private javax.swing.JComboBox cmbScoreHallazgo;
    private javax.swing.JComboBox cmbScoreRecomendacion;
    private com.toedter.calendar.JDateChooser dateFin;
    private com.toedter.calendar.JDateChooser dateInicio;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JLabel lblEstado;
    private javax.swing.JTabbedPane tabPan;
    private javax.swing.JTable tblHallazgos;
    private javax.swing.JTable tblPapelTrabajo;
    private javax.swing.JTable tblRecomendaciones;
    private javax.swing.JTextField txtContacto;
    private javax.swing.JTextField txtCorreo;
    private javax.swing.JTextField txtDescripcion;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtDocumentoAsociado;
    private javax.swing.JTextField txtMarcoReferencia;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtObjetivos;
    private javax.swing.JTextField txtRUC;
    private javax.swing.JTextField txtRazonSocial;
    private javax.swing.JTextField txtRecomendacion;
    private javax.swing.JTextField txtTelefono;
    private javax.swing.JTextField txtTituloHallazgo;
    private javax.swing.JTextField txtTituloRecomendacion;
    // End of variables declaration//GEN-END:variables

    private void mostrarMantProyectos() {
        ventanaPrincipal.panelProyectos.mantenimientoProyectos.setVisible(true);
        ventanaPrincipal.panelProyectos.remove(this);
    }

    /**************************************************************************
     ************************************************************************** 
     ************************* Informacion Proyecto ***************************
     **************************************************************************
     *************************************************************************/
    void desbloquearCampos(boolean desbloquear) {
        txtNombre.setEditable(desbloquear);
        txtDescripcion.setEditable(desbloquear);
        txtObjetivos.setEditable(desbloquear);
        txtMarcoReferencia.setEditable(desbloquear);
        dateInicio.setEnabled(desbloquear);
        dateFin.setEnabled(desbloquear);
        //datos cliente
        txtRUC.setEditable(desbloquear);
        txtRazonSocial.setEditable(desbloquear);
        txtContacto.setEditable(desbloquear);
        txtCorreo.setEditable(desbloquear);
        txtTelefono.setEditable(desbloquear);
        txtDireccion.setEditable(desbloquear);
    }

    private void getDatos() {
        txtNombre.getText();
        txtDescripcion.getText();
        txtObjetivos.getText();
        txtMarcoReferencia.getText();
        //datos cliente
        txtRUC.getText();
        txtRazonSocial.getText();
        txtContacto.getText();
        txtCorreo.getText();
        txtTelefono.getText();
        txtDireccion.getText();
    }

    private void buscarMarco() {
        BusquedaMarcoReferencia ventBusqueda = new BusquedaMarcoReferencia(this);
        ventBusqueda.setVisible(true);
    }

    private void completarProyecto() {
        //cambiar estado
        proyecto.setEstado(Proyecto.ESTADO_COMPLETADO);
        btnGenerarInforme.setEnabled(true);
        //bloquear todos los botones de modificación xD
        btnGuardar.setEnabled(false);
        btnEditar.setEnabled(false);
        //de papeles
        btnCompletarPt.setEnabled(false);
        btnEditarPT.setEnabled(false);
        btnEliminarPt.setEnabled(false);
        btnRefrescarPT.setEnabled(false);
        //de hallazgos
        btnNuevoHallazgo.setEnabled(false);
        btnAgregarHallazgo.setEnabled(false);
        btnEditarHallazgo.setEnabled(false);
        btnEliminarHallazgo.setEnabled(false);
        btnRefrescarHallazgos.setEnabled(false);
        //de recomendaciones
        btnNuevaRecomendacion.setEnabled(false);
        btnAgregarRecomendacion.setEnabled(false);
        btnEditarRecomendacion.setEnabled(false);
        btnEliminarRecomendacion.setEnabled(false);
        btnRefrescarRecomendaciones.setEnabled(false);
        
    }

    void setProyecto(Proyecto proyecto) {
        this.proyecto = proyecto;
    }

    private void llenarInfoProyecto(Proyecto proyecto) {
        txtNombre.setText(proyecto.getNombre());
        txtDescripcion.setText(proyecto.getDescripcion());
        txtMarcoReferencia.setText(proyecto.getMarcoReferencia());
        txtObjetivos.setText(proyecto.getObjetivos());
        dateInicio.setDate(proyecto.getFechaInicio());
        dateFin.setDate(proyecto.getFechaFin());
        lblEstado.setText("Creado");

        cliente = clienteBl.buscarPorId(proyecto.getCliente().getIdCliente());
        txtRUC.setText("" + cliente.getRuc());
        txtRazonSocial.setText(cliente.getRazonSocial());
        txtContacto.setText(cliente.getNombreContacto());
        txtDireccion.setText(cliente.getDireccion());
        txtCorreo.setText(cliente.getCorreo());
        txtTelefono.setText(cliente.getTelefonoContacto());

        papelesTrabajo = papelTrabajoBl.buscarPorIdProyecto(proyecto.getIdproyecto());
        llenarTablaPapeles(papelesTrabajo);
    }

    private void guardarCambios() {
        //info cliente
        cliente.setCorreo(txtCorreo.getText().trim());
        cliente.setRazonSocial(txtRazonSocial.getText().trim());
        cliente.setNombreContacto(txtContacto.getText().trim());
        cliente.setTelefonoContacto(txtTelefono.getText().trim());
        cliente.setDireccion(txtDireccion.getText().trim());

        clienteBl.guardar(cliente);

        //infoProyecto
        proyecto.setNombre(txtNombre.getText().trim());
        proyecto.setDescripcion(txtDescripcion.getText().trim());
        proyecto.setObjetivos(txtObjetivos.getText().trim());

        proyectoBl.guardar(proyecto);
    }

    private void generarInforme() {
        proyectoBl.generarInforme(proyecto);
    }

    private void generarReporte() {
        //@TO-DO
    }

    /*************************************************************************
     ************************************************************************** 
     ************************* Papeles de Trabajo *****************************
     **************************************************************************
     *************************************************************************/
    public void buscarPapeles() {
        papelesTrabajo = papelTrabajoBl.buscarPorIdProyecto(proyecto.getIdproyecto());
        llenarTablaPapeles(papelesTrabajo);
    }

    void ocultarIdTablaPt() {
        tblPapelTrabajo.getColumn("Id").setWidth(0);
        tblPapelTrabajo.getColumn("Id").setMaxWidth(0);
        tblPapelTrabajo.getColumn("Id").setMinWidth(0);
    }

    private void llenarTablaPapeles(List papeles) {
        Vector<String> tableHeaders = new Vector<String>();
        Vector tableData = new Vector();
        tableHeaders.add("Id");
        tableHeaders.add("Nombre");

        PapelTrabajo p;
        for (Object o : papeles) {
            p = (PapelTrabajo) o;
            Vector<Object> fila = new Vector<Object>();
            fila.add(p.getIdPapelTrabajo());
            fila.add(p.getNombre());
            tableData.add(fila);
        }

        tblPapelTrabajo.setModel(new DefaultTableModel(tableData, tableHeaders));
        ocultarIdTablaPt();
    }

    private void completarPT() {
        PapelTrabajo papelTrabajo = getPapelTrabajoSeleccionado();
        new LlenadoPapelTrabajo(papelTrabajo, Principal.MODO_LLENADO, ventanaPrincipal).setVisible(true);
    }

    private PapelTrabajo getPapelTrabajoSeleccionado() {
        int idPtSeleccionado = Integer.parseInt(tblPapelTrabajo.getValueAt(tblPapelTrabajo.getSelectedRow(), 0).toString());
        return new PapelTrabajoBl().buscarPorId(idPtSeleccionado);
    }

    private void mostrarPapelTrabajo() {
        PapelTrabajo papelTrabajo = getPapelTrabajoSeleccionado();
        new LlenadoPapelTrabajo(papelTrabajo, Principal.MODO_LECTURA, ventanaPrincipal).setVisible(true);
    }

    private void agregarPapelTrabajo() {
        PlantillaMarcoReferencia marco = new PlantillaMarcoReferenciaBl().buscarPorId(proyecto.getIdMarcoReferencia());
        new LlenadoPapelTrabajo(marco, proyecto, ventanaPrincipal).setVisible(true);
    }

    private void editarPapelTrabajo() {
        PapelTrabajo p = getPapelTrabajoSeleccionado();
        new LlenadoPapelTrabajo(p, Principal.MODO_EDICION, ventanaPrincipal).setVisible(true);
    }

    private void eliminarPapelTrabajo() {
        PapelTrabajo p = getPapelTrabajoSeleccionado();
        if (new PapelTrabajoBl().eliminarPorId(p.getIdPapelTrabajo())) {
            JOptionPane.showMessageDialog(this, "Ha eliminado el papel de trabajo", "Confirmación", JOptionPane.INFORMATION_MESSAGE);
            llenarTablaPapeles(papelesTrabajo);
        } else {
            JOptionPane.showMessageDialog(this, "Ha ocurrido un error en la eliminación. \n Por favor, intente nuevamente.", "Error", JOptionPane.ERROR_MESSAGE);
        }

    }

    /*************************************************************************
     ************************************************************************** 
     ************************ Redaccion de Hallazgos **************************
     **************************************************************************
     *************************************************************************/
    private void buscarHallazgos() {
        Hallazgo hallazgo = new Hallazgo();
        hallazgo.setTitulo(txtTituloHallazgo.getText().trim());
        hallazgo.setScore(cmbScoreHallazgo.getSelectedIndex());
        hallazgo.setProyecto(proyecto);
        if (documentoAsociado == null) {
            hallazgo.setPapelTrabajo(null);
        } else {
            hallazgo.setPapelTrabajo(documentoAsociado);
        }
        List listaHallazgos = new HallazgoBl().buscarPorCriterios(hallazgo);
        llenarTablaHallazgos(listaHallazgos);
    }

    private void buscarDocumentoAsociado() {
        //@TO-DO
        //despegar ventana
    }

    private void llenarTablaHallazgos(List listaHallazgos) {
        Vector<String> tableHeaders = new Vector<String>();
        Vector tableData = new Vector();

        tableHeaders.add("Id");
        tableHeaders.add("Hallazgo");
        tableHeaders.add("Score");

        for (Object o : listaHallazgos) {
            Hallazgo h = (Hallazgo) o;
            Vector<Object> fila = new Vector<Object>();
            fila.add(h.getIdHallazgo());
            fila.add(h.getTitulo());
            fila.add(h.getScore());
            tableData.add(fila);
        }

        tblHallazgos.setModel(new DefaultTableModel(tableData, tableHeaders));
        ocultarIdTablaHallazgos();
    }

    private void editarHallazgo() {
        Hallazgo h = getHallazgoSeleccionado();
        limpiarVentanaHallazgos();
        new RedaccionHallazgos(proyecto.getIdproyecto(), Principal.MODO_EDICION, h, ventanaPrincipal).setVisible(true);
        //refrescar tabla
    }

    private Hallazgo getHallazgoSeleccionado() {
        int idHallazgo = Integer.parseInt((tblHallazgos.getValueAt(tblHallazgos.getSelectedRow(), 0)).toString());
        return new HallazgoBl().buscarPorId(idHallazgo);
    }

    private void limpiarVentanaHallazgos() {
        txtTituloHallazgo.setText("");
        txtDocumentoAsociado.setText("");
        documentoAsociado = null;
        cmbScoreHallazgo.setSelectedIndex(0);
    }

    private void eliminarHallazgo() {
        Hallazgo h = getHallazgoSeleccionado();
        if (new HallazgoBl().eliminar(h)) {
            JOptionPane.showMessageDialog(this, "Ha eliminado el hallazgo", "Confirmación", JOptionPane.INFORMATION_MESSAGE);
            buscarHallazgos();
        } else {
            JOptionPane.showMessageDialog(this, "Ha ocurrido un error en la eliminación. \n Por favor, intente nuevamente.", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }

    private void verHallazgo() {
        Hallazgo h = getHallazgoSeleccionado();
        limpiarVentanaHallazgos();
        new RedaccionHallazgos(proyecto.getIdproyecto(), Principal.MODO_LECTURA, h, ventanaPrincipal).setVisible(true);
    }
    
    /*************************************************************************
     ************************************************************************** 
     ********************* Redaccion de Recomendaciones ***********************
     **************************************************************************
     *************************************************************************/
    private void ocultarIdTablaRecomendaciones() {
/*        tblRecomendaciones.getColumn("Id").setWidth(0);
        tblRecomendaciones.getColumn("Id").setMaxWidth(0);
        tblRecomendaciones.getColumn("Id").setMinWidth(0);*/
    }

    private void buscarRecomendaciones() {
        Recomendacion r = new Recomendacion();
        r.setTitulo(txtTituloRecomendacion.getText().trim());
        r.setRecomendacion(txtRecomendacion.getText().trim());
        r.setScore(cmbScoreRecomendacion.getSelectedIndex());
        r.setProyecto(proyecto);

        List recomendaciones = new RecomendacionBl().buscarPorCriterios(r);
        llenarTablaRecomendaciones(recomendaciones);
    }

    private void llenarTablaRecomendaciones(List recomendaciones) {
        Vector<String> tableHeaders = new Vector<String>();
        Vector tableData = new Vector();

        tableHeaders.add("Id");
        tableHeaders.add("Recomendación");
        tableHeaders.add("Score");

        for (Object o : recomendaciones) {
            Recomendacion r = (Recomendacion) o;
            Vector<Object> fila = new Vector<Object>();
            fila.add(r.getIdRecomendacion());
            fila.add(r.getTitulo());
            fila.add(r.getScore());
            tableData.add(fila);
        }

        tblRecomendaciones.setModel(new DefaultTableModel(tableData, tableHeaders));
        ocultarIdTablaRecomendaciones();
    }

    private void editarRecomendacion() {
        Recomendacion r = getRecomendacionSeleccionada();
        limpiarVentanaRecomendaciones();
        new RedaccionRecomendaciones(proyecto.getIdproyecto(), Principal.MODO_EDICION, r, ventanaPrincipal).setVisible(true);
        //refrescar tabla
    }

    private Recomendacion getRecomendacionSeleccionada() {
        int idRecomendacion = Integer.parseInt((tblRecomendaciones.getValueAt(tblRecomendaciones.getSelectedRow(), 0)).toString());
        return new RecomendacionBl().buscarPorId(idRecomendacion);
    }

    private void limpiarVentanaRecomendaciones() {
        txtTituloRecomendacion.setText("");
        txtRecomendacion.setText("");
        cmbScoreRecomendacion.setSelectedIndex(0);
    }

    private void eliminarRecomendacion() {
        Recomendacion r = getRecomendacionSeleccionada();
        if (new RecomendacionBl().eliminar(r)) {
            JOptionPane.showMessageDialog(this, "Ha eliminado la recomendación", "Confirmación", JOptionPane.INFORMATION_MESSAGE);
            buscarRecomendaciones();
        } else {
            JOptionPane.showMessageDialog(this, "Ha ocurrido un error en la eliminación. \n Por favor, intente nuevamente.", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }

    private void limpiar() {
    //    throw new UnsupportedOperationException("Not yet implemented");
    }

    /**
     * @param marcoReferencia the marcoReferencia to set
     */
    public void setMarcoReferencia(PlantillaMarcoReferencia marcoReferencia) {        
        this.marcoReferencia = marcoReferencia;
        txtMarcoReferencia.setText(marcoReferencia.getNombre());
    }

    private void verRecomendacion() {
        Recomendacion r = getRecomendacionSeleccionada();
        limpiarVentanaRecomendaciones();
        new RedaccionRecomendaciones(proyecto.getIdproyecto(), Principal.MODO_LECTURA, r, ventanaPrincipal).setVisible(true);
    }


}
